const apiLogServer = require('./api/apiLogServer')
const data = require('./data/auth.json')

function logServer(port) {
  const auth = data.auth

  const server = data.server || {}
  const ser_ip = server.ip
  // const ser_port = server.port
  const device = data.device
  const dev_ip = device.ip

  return new Promise((resolve, reject) => {
    if (auth) {
      apiLogServer(dev_ip, auth,ser_ip,port).then(e => {
        console.log('成功了', e)
        resolve({e, data})
      }).catch(e=> {
        reject(e.data)
      })
    } else {
      reject('失败了 222')
    }
  })
}

module.exports = logServer